package net.zoneland.knowledge.dao;

import net.zoneland.knowledge.model.AttachmentPreviewForm;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface AttachmentPreviewMapper {


    @Insert({
            "insert into AITK_PARTY_ATTACHMENT_PREVIEW ",
            "(ID, FILE_ID, FILE_NAME, DOWN_LOAD_URL,TYPE,STATUS,FILE_TABLE_ID,SOURCE_QA_BANK) ",
            "values (#{id,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR}, ",
            "#{fileName,jdbcType=VARCHAR}, #{downLoadUrl,jdbcType=VARCHAR}, ",
            "#{type,jdbcType=VARCHAR}, #{status,jdbcType=DECIMAL}, ",
            "#{fileTableId,jdbcType=VARCHAR}, #{sourceQaBank,jdbcType=BOOLEAN})"
    })
    int insert(final AttachmentPreviewForm form);


    @Select({
        "select",
        "ID, FILE_ID, FILE_NAME, FILE_CONTENT, DOWN_LOAD_URL, TYPE, STATUS, FILE_TABLE_ID, SOURCE_QA_BANK ",
        "from AITK_PARTY_ATTACHMENT_PREVIEW",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="FILE_ID", property="fileId", jdbcType=JdbcType.VARCHAR),
        @Result(column="FILE_NAME", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="FILE_CONTENT", property="fileContent", jdbcType=JdbcType.CLOB),
        @Result(column="DOWN_LOAD_URL", property="downLoadUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="TYPE", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="STATUS", property="status", jdbcType=JdbcType.DECIMAL),
        @Result(column="FILE_TABLE_ID", property="fileTableId", jdbcType=JdbcType.VARCHAR),
        @Result(column="SOURCE_QA_BANK", property="sourceQaBank", jdbcType=JdbcType.BOOLEAN)
    })
    AttachmentPreviewForm selectByPrimaryKey(final String id);


    @Update({
        "update AITK_PARTY_ATTACHMENT_PREVIEW ",
        "set status = #{status,jdbcType=DECIMAL} ",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(final AttachmentPreviewForm form);
}